﻿Page({
  data: {
      user: "",
      openid: "1234567897",
      teacherurl: "/pages/student/student?user=teacher&openid=",
      studenturl: "/pages/student/student?user=student&openid="
  },
  onLoad: function(e) {},
  openidget: function(e) {
      var n = this;
      wx.cloud.callFunction({
          name: "getopenid",
          data: {
              message: "getopenid"
          }
      }).then(function(t) {
          if (console.log(t), console.log(t.result.openid), n.setData({
              openid: t.result.openid,
              teacherurl: n.data.teacherurl + t.result.openid,
              studenturl: n.data.studenturl + t.result.openid
          }), console.log(n.data.teacherurl), "teacher" == e.currentTarget.dataset.user) {
              wx.setStorageSync("user", {
                  info: "teacher",
                  openid: n.data.openid
              });
              var o = wx.getStorageSync("user");
              console.log(o), console.log("缓存成功"), wx.reLaunch({
                  url: n.data.teacherurl
              });
          } else {
              wx.setStorageSync("user", {
                  info: "student",
                  openid: n.data.openid
              });
              o = wx.getStorageSync("user");
              console.log(o), console.log("缓存成功"), wx.reLaunch({
                  url: n.data.studenturl
              });
          }
      }).catch(function(e) {
          console.log(e);
      });
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  onShareAppMessage: function() {}
});